package com.springmvc.demo.mapper;

import java.util.List;

import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import com.baomidou.mybatisplus.annotations.TableName;
import com.baomidou.mybatisplus.mapper.BaseMapper;
import com.springmvc.demo.model.User;

@Mapper
@TableName("t_user")
public interface UserMapper extends BaseMapper<User>{
    @Select("SELECT * FROM t_user WHERE userid = #{userid}")
    User findUserByUserid(@Param("userid")String userid);
    
    @Select("SELECT * FROM t_user WHERE (userid = #{userid} AND pwd=#{pwd}) AND roleid=#{roleid}")
    User login(User user);
    
    @Select("SELECT * FROM t_user")
    List<User> listAllUser();
    
    @Delete("Delete FROM t_user where userid=#{userid}")
    int deleteUser(@Param("userid")String userid);
    
    @Insert("Insert Into t_user (userid,fullname,pwd,type,roleid) VALUES(#{userid},#{fullname},#{pwd},#{type},#{roleid})")
    int insertUser(User u);
    
    @Update("Update t_user SET userid=#{userid},fullname=#{fullname},pwd=#{pwd},type=#{type}")
    int updateUser(User u);
    
    
//    @Insert("Insert Into t_user ")
//    void insertUser();
}
